﻿namespace GarminConnect
{
    /// <summary>
    /// 睡眠数据传输对象
    /// </summary>
    public class SleepDTO
    {
        public int Id { get; set; }
        public int UserProfilePK { get; set; }
        public string? CalendarDate { get; set; }
        public int SleepTimeSeconds { get; set; }
        public int NapTimeSeconds { get; set; }
        public bool SleepWindowConfirmed { get; set; }
        public string? SleepWindowConfirmationType { get; set; }
        public long SleepStartTimestampGMT { get; set; }
        public long SleepEndTimestampGMT { get; set; }
        public long SleepStartTimestampLocal { get; set; }
        public long SleepEndTimestampLocal { get; set; }
        public long? AutoSleepStartTimestampGMT { get; set; }
        public long? AutoSleepEndTimestampGMT { get; set; }
        public int? SleepQualityTypePK { get; set; }
        public int? SleepResultTypePK { get; set; }
        public int UnmeasurableSleepSeconds { get; set; }
        public int DeepSleepSeconds { get; set; }
        public int LightSleepSeconds { get; set; }
        public int RemSleepSeconds { get; set; }
        public int AwakeSleepSeconds { get; set; }
        public bool DeviceRemCapable { get; set; }
        public bool Retro { get; set; }
        public bool SleepFromDevice { get; set; }
        public double AverageRespirationValue { get; set; }
        public double LowestRespirationValue { get; set; }
        public double HighestRespirationValue { get; set; }
        public int AwakeCount { get; set; }
        public double AvgSleepStress { get; set; }
        public string? AgeGroup { get; set; }
        public string? SleepScoreFeedback { get; set; }
        public string? SleepScoreInsight { get; set; }
        public SleepScores SleepScores { get; set; } = null!;
        public int SleepVersion { get; set; }
    }

    /// <summary>
    /// 睡眠评分相关数据
    /// </summary>
    public class SleepScores
    {
        public SleepScoreDetail TotalDuration { get; set; } = null!;
        public SleepScoreDetail Stress { get; set; } = null!;
        public SleepScoreDetail AwakeCount { get; set; } = null!;
        public SleepScoreOverall Overall { get; set; } = null!;
        public SleepScoreRemPercentage RemPercentage { get; set; } = null!;
        public SleepScoreDetail Restlessness { get; set; } = null!;
        public SleepScoreLightPercentage LightPercentage { get; set; } = null!;
        public SleepScoreDeepPercentage DeepPercentage { get; set; } = null!;
    }

    /// <summary>
    /// 睡眠评分详情
    /// </summary>
    public class SleepScoreDetail
    {
        public string? QualifierKey { get; set; }
        public int OptimalStart { get; set; }
        public int OptimalEnd { get; set; }
    }

    /// <summary>
    /// 睡眠评分总体信息
    /// </summary>
    public class SleepScoreOverall
    {
        public int Value { get; set; }
        public string? QualifierKey { get; set; }
    }

    /// <summary>
    /// 睡眠评分REM百分比
    /// </summary>
    public class SleepScoreRemPercentage
    {
        public int Value { get; set; }
        public string? QualifierKey { get; set; }
        public int OptimalStart { get; set; }
        public int OptimalEnd { get; set; }
        public int IdealStartInSeconds { get; set; }
        public int IdealEndInSeconds { get; set; }
    }

    /// <summary>
    /// 睡眠评分浅睡百分比
    /// </summary>
    public class SleepScoreLightPercentage
    {
        public int Value { get; set; }
        public string? QualifierKey { get; set; }
        public int OptimalStart { get; set; }
        public int OptimalEnd { get; set; }
        public int IdealStartInSeconds { get; set; }
        public int IdealEndInSeconds { get; set; }
    }

    /// <summary>
    /// 睡眠评分深睡百分比
    /// </summary>
    public class SleepScoreDeepPercentage
    {
        public int Value { get; set; }
        public string? QualifierKey { get; set; }
        public int OptimalStart { get; set; }
        public int OptimalEnd { get; set; }
        public int IdealStartInSeconds { get; set; }
        public int IdealEndInSeconds { get; set; }
    }

    /// <summary>
    /// 睡眠运动数据
    /// </summary>
    public class SleepMovement
    {
        public string? StartGMT { get; set; }
        public string? EndGMT { get; set; }
        public int ActivityLevel { get; set; }
    }

    /// <summary>
    /// 睡眠阶段数据
    /// </summary>
    public class SleepLevels
    {
        public string? StartGMT { get; set; }
        public string? EndGMT { get; set; }
        public int ActivityLevel { get; set; }
    }

    /// <summary>
    /// 睡眠呼吸数据
    /// </summary>
    public class WellnessEpochRespirationDataDTO
    {
        public long StartTimeGMT { get; set; }
        public double RespirationValue { get; set; }
    }

    /// <summary>
    /// 睡眠心率数据
    /// </summary>
    public class SleepHeartRate
    {
        public int Value { get; set; }
        public long StartGMT { get; set; }
    }

    /// <summary>
    /// 睡眠身体电池数据
    /// </summary>
    public class SleepBodyBattery
    {
        public int Value { get; set; }
        public long StartGMT { get; set; }
    }

    /// <summary>
    /// 睡眠数据类，包含所有相关的睡眠信息和统计数据
    /// </summary>
    public class SleepData
    {
        public SleepDTO DailySleepDTO { get; set; } = null!;
        public List<SleepMovement> SleepMovement { get; set; } = [];
        public bool RemSleepData { get; set; }
        public List<SleepLevels> SleepLevels { get; set; } = [];
        public int RestlessMomentsCount { get; set; }
        public List<WellnessEpochRespirationDataDTO> WellnessEpochRespirationDataDTOList { get; set; } = [];
        public List<SleepHeartRate> SleepHeartRate { get; set; } = [];
        public List<SleepBodyBattery> SleepBodyBattery { get; set; } = [];
        public double AvgOvernightHrv { get; set; }
        public string? HrvStatus { get; set; }
        public double BodyBatteryChange { get; set; }
        public int RestingHeartRate { get; set; }
    }

}
